﻿///////////////////////////////////////////////////////////////////////////////
//
// This file is part of the BassDrop project
//   https://code.google.com/p/bass-drop/
//
//
// Creator:	Gergely Krajcsovszki (krajcsovszkig@hotmail.com)
// Date:	2013-08-05 12:15
//
//
// Copyright © 2013-2014. Gergely Krajcsovszki
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace BassDrop.Core.Common.Options.Items
{
	/// <summary>
	/// An item that can be put into an options list
	/// </summary>
	public abstract class OptionsItemBase : INotifyPropertyChanged
	{
		/// <summary>
		/// Name/title of the item
		/// </summary>
		private string m_name = null;

		/// <summary>
		/// Name/title of the item
		/// </summary>
		public string Name
		{
			get
			{
				return m_name;
			}

			set
			{
				if ( value == m_name )
				{
					return;
				}

				m_name = value;
				OnPropertyChanged( "Name" );
			}
		}

		/// <summary>
		/// The description of the item.
		/// </summary>
		private string m_description = null;

		/// <summary>
		/// The description of the item.
		/// Shown typically in tooltips
		/// </summary>
		public string Description
		{
			get
			{
				return m_description;
			}

			set
			{
				if ( value == m_description )
				{
					return;
				}

				m_description = value;
				OnPropertyChanged( "Description" );
			}
		}

		/// <summary>
		/// If this item is displayed as a user control, gets or sets whether it can be used.
		/// </summary>
		private bool m_enabled = true;

		/// <summary>
		/// If this item is displayed as a user control, gets or sets whether it can be used.
		/// </summary>
		public bool Enabled
		{
			get
			{
				return m_enabled;
			}

			set
			{
				if ( value == m_enabled )
				{
					return;
				}

				m_enabled = value;
				OnPropertyChanged( "Enabled" );
			}
		}


		/// <summary>
		/// Creates a new simple options item
		/// </summary>
		/// <param name="name">Name/title of the item</param>
		/// <param name="description">The description of the item. Shown typically in tooltips</param>
		protected OptionsItemBase( string name, string description )
		{
			m_name = name;
			m_description = description;
		}

		#region INotifyPropertyChanged Members

		/// <summary>
		/// Event fired when the value of a property of this object changes
		/// </summary>
		public event PropertyChangedEventHandler PropertyChanged;

		#endregion

		/// <summary>
		/// Fires a PropertyChanged event for the property with the passed name
		/// </summary>
		/// <param name="propertyName"></param>
		protected void OnPropertyChanged( string propertyName )
		{
			if ( PropertyChanged != null )
			{
				PropertyChanged( this, new PropertyChangedEventArgs( propertyName ) );
			}
		}
	}
}
